﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/WebSite.Master" CodeBehind="EnterpriseInput.aspx.cs" Inherits="RN.ERP.Web.Enterprise.EnterpriseInput" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link rel="Stylesheet" type="text/css" href="../Scripts/ligerUI/skins/Aqua/css/ligerui-all.css" />
    <link href="../Styles/skins/blue/css/style_msg.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../Scripts/ligerUI/js/ligerui.min.js"></script>
    <script type="text/javascript">
    var empGuid;
    var flag;
    var gid;
    var entityid;
    var classid;
    var entityname;
    $(function () {
        empGuid = $("#<%= hdEmpGuid.ClientID%>").val();
        flag = $("#<%= hdFlag.ClientID%>").val();
        gid = $("#<%= hdGid.ClientID%>").val();
        entityid = $("#<%= hdEntityGuid.ClientID%>").val();
        entityname = $("#<%= hdEntityName.ClientID%>").val();
        classid = $("#<%= hdnClassID.ClientID%>").val();

        $("#txtCorpName").ligerComboBox(
                {
                    url: '../handlers/ComboBoxHandler.ashx?Action=RelCorp',
                    valueField: 'value',
                    textField: 'name',
                    selectBoxWidth: 300,
                    autocomplete: true,
                    width: 300
                }
            );

        if ($("#<%= hdStatus.ClientID%>").val() == "1") {
            ////编辑初始化
            var proData = [{ value: entityid, name: entityname}];
            if (classid == 1001) {
                proData = [{ value: "", name: entityname}];
            }
            var manager = $("#txtCorpName").ligerGetComboBoxManager();
            manager.setData(proData);
            manager.setText(entityname);
        }

        $("#btnSave").click(function () {
            var corpname = $("#txtCorpName").val();
            entityid = $("#txtCorpName").ligerGetComboBoxManager().getValue();
            if (!entityid) {
                classid = 1001;
            }
            else {
                classid = 1000;
            }
            if (!corpname) {
                OpenAlert("请输入单位名称");
            }
            else {
                $.getJSON("../handlers/PsnEmpInfoHandler.ashx", { "action": "RelationSave", "empGuid": empGuid, "gid": gid, "Flag": flag, "EntityName": corpname, "EntityGuid": entityid, "ClassId": classid, "rand": Math.random() }, function (data) {
                    if (data.length == 0 || data == null) {
                        OpenAlert("未查询到有效数据！");
                        return false;
                    }
                    if (!data.Result) {
                        OpenAlert(data.Message);
                        return false;
                    }
                    else {
                        OpenAlert(data.Message);
                        returnToParent(0);
                    }
                });
            }
        });
    }
);


    /*关闭窗口*/

    function returnToParent(result) {
        var oArg = new Object();
        oArg.childWinName = "Relation";
        oArg.Result = result;
        //        top.ChildDialogCallBack = "OnClientClose";
        //        top.ChildDialogClose(oArg);
        parent.window.OnClientClose(oArg);
        window.parent.$.ligerDialog.close(); ////关闭dialog
        parent.$(".l-dialog,.l-window-mask").hide(); ////去除父窗体遮罩层
        parent.window.focus();
    }
    function OpenAlert(text) {
        $.ligerDialog.warn(text);
        return false;
    }

    function selectTag(showContent, selfObj) {
        // 操作标签
        var tag = document.getElementById("tags").getElementsByTagName("li");
        var taglength = tag.length;
        for (i = 0; i < taglength; i++) {
            tag[i].className = "";
        }
        selfObj.parentNode.className = "selectTag";
        // 操作内容
        for (i = 0; j = document.getElementById("tagContent" + i); i++) {
            j.style.display = "none";
        }
        document.getElementById(showContent).style.display = "block";
    }

    </script>
    <style type="text/css">
        .text_css
        {
            border: 2px;
            height: 24px;
            line-height: 24px;
            margin-top: 8px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" style="table-layout:fixed;">
        <tr>
            <td class="xx_m  tt_xx_l"></td>
            <td class="xx_m  tt_xx_icon"></td>
            <td style="width:auto;" class="xx_m">利害关系单位</td>
            <td style="width:14px;"><img src="../images/xx_r.jpg" width="14" height="33" /></td>
        </tr>
        <tr>
            <td class="left_con">
                &nbsp;
            </td>
            <td colspan="2" style="padding-left: 6px; padding-right: 6px;" valign="top">
            <div id="con">
            <ul id="tags">
                <li class="selectTag"><a onclick="selectTag('tagContent0',this)" href="javascript:void(0)">
                    单位添加</a> </li>
            </ul>
            <div id="tagContent">
                <!--#企业列表-->
                <div class="tagContent selectTag" id="tagContent0">
                    <div class="xian">
                        <div class="about_title">
                            请选择利害关系单位</div>
                        <div class="i-con-cn">
      <%--                      <input type="button" class="xtbiao" id="btnSearch" value="查询" />--%>
                        </div>
                    </div>
                    <asp:Panel ID="Panel1" runat="server" Style="margin-bottom: 5px;">
                        <table style="width: 100%; height: 40px; padding-bottom: 10px; padding-top: 10px;
                            background-color: #eaeaea; text-align: center;">
                            <tr>
                                <td width="50">
                                    企业名称
                                </td>
                                <td width="110">
                                                <input type="text" id="txtCorpName"  />   
                                </td>
                            </tr>
                              <tr>
                            <td colspan="2" align="center">
                                        <div class="icon01 IE6png" style="float:left;margin-left:300px" >
                                            <a style="clear:both;" id="btnSave" href="javascript:void(0);">保存</a>
                                        </div>
                            </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </div>
                <!--#企业列表结束-->
                </div>
                </div>
            </td>
            <td class="right_con">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td class="con_m tt_left_bottom">&nbsp;</td>
            <td colspan="2" class="con_m">&nbsp;</td>
            <td class="tt_right_bottom">&nbsp;</td>
        </tr>
    </table>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="WebBlue" EnableShadow="true">
    </telerik:RadWindowManager>
    <asp:HiddenField ID="hdnClassID" runat="server" />
    <asp:HiddenField ID="hdnCondition" runat="server" />
    <input id="hdEmpGuid" type="hidden" runat="server" value="" /> 
    <input id="hdFlag" type="hidden" runat="server" value="" />
    <input id="hdGid" type="hidden" runat="server" value="" />
    <input id="hdEntityGuid" type="hidden" runat="server" value="" />
    <input id="hdEntityName" type="hidden" runat="server" value="" />
    <input id="hdStatus" type="hidden" runat="server" value="0" />
    </asp:Content>